﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;

namespace HMEngine.HMComponents {
    internal sealed class HMComponentManager : DrawableGameComponent {
        private static readonly Dictionary<string, IHMComponent> masterList = new Dictionary<string, IHMComponent>();
        private static readonly Dictionary<string, IHMRenderable> renderable = new Dictionary<string, IHMRenderable>();

        internal HMComponentManager(Game game) : base(game) { }

        public static void AddComponent(string name, IHMComponent component) {
            masterList.Add(name, component);

            if (component is IHMRenderable) {
                renderable.Add(name, (IHMRenderable)component);
            }
        }

        public override void Draw(GameTime gameTime) {
            foreach (IHMRenderable render in renderable.Values) {
                render.Render(GraphicsDevice);
            }
        }
    }
}